local PLUGIN = {}
PLUGIN.Title = "Ban Status"
PLUGIN.Description = "Checks to see if a player is banned."
PLUGIN.Author = "Remscar"
PLUGIN.ChatCommand = "banstatus"
PLUGIN.Usage = "<steamid|nick>"
PLUGIN.Privileges = { "banstatus" }

function PLUGIN:Call( ply, args )
	if ( ply:EV_HasPrivilege( "banstatus" ) ) then
		if ( args[1] ) then
			local uniqueID
			
			if ( string.match( args[1], "STEAM_[0-5]:[0-9]:[0-9]+" ) ) then
				uniqueID = evolve:UniqueIDByProperty( "steamid", args[1], true )
			else
				uniqueID = evolve:UniqueIDByProperty( "nick", args[1], false )
			end
			
			if ( uniqueID and evolve:IsBanned( uniqueID ) ) then
				local BanAdminID = evolve:GetProperty(uniqueID, "banadmin")
				local Nick = evolve:GetProperty( uniqueID, "nick" )
				local Steam = evolve:GetProperty( uniqueID, "steamid")
				local BanAdmin = evolve:GetProperty(BanAdminID, "nick")
				local BanEnd = tonumber(evolve:GetProperty(uniqueID, "banend")) - os.time()
				local BanReason = evolve:GetProperty(uniqueID, "banreason")
				local BanTime = evolve:FormatTime(BanEnd)
				evolve:Notify( ply, evolve.colors.blue, "Player ".. Nick .. " is banned for " .. BanTime .. " by the admin " .. BanAdmin .. " for " .. BanReason)
				evolve:Notify( ply, evolve.colors.green, "Their STEAMID is " .. Steam)
			elseif ( uniqueID ) then
				evolve:Notify( ply, evolve.colors.red, evolve:GetProperty( uniqueID, "Nick" ) .. " is not currently banned." )
			else
				evolve:Notify( ply, evolve.colors.red, "No matching players found!" )
			end
		else
			evolve:Notify( ply, evolve.colors.red, "You need to specify a SteamID or nickname!" )
		end
	else
		evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed )
	end
end

evolve:RegisterPlugin( PLUGIN )